local jsrg_bahu = fk.CreateSkill {
  name = "jsrg_bahu",
  tags={Skill.Compulsory}
}

jsrg_bahu:addEffect(fk.EventPhaseStart, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Start
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, self.name)
  end,
})


jsrg_bahu:addEffect('targetmod', {
  residue_func = function(self, player, skill, scope)
    if player:hasSkill(self) and skill.trueName == "slash_skill"
      and scope == Player.HistoryPhase then
      return 1
    end
  end,
})


jsrg_bahu:addTest(function(room, me)
  local comp2=room.players[2]
  local slash=Fk:getCardById(1)
  FkTest.runInRoom(function()
    room:handleAddLoseSkills(me, "jsrg_bahu")
  end)
  FkTest.runInRoom(function()
    local data = { ---@type TurnDataSpec
      who = me,
      reason = "game_rule",
      phase_table = { Player.Start }
    }
    GameEvent.Turn:create(TurnData:new(data)):exec()
  end) 
  lu.assertEquals(#me:getCardIds("h"), 1)
  
  FkTest.setRoomBreakpoint(me, "PlayCard")
  FkTest.runInRoom(function()
    room:obtainCard(me, slash)
    Request:new(me, "PlayCard"):ask()
    local use = { ---@type UseCardDataSpec
    from=me,
    tos={comp2},
    card=slash
  }
  room:useCard(use)
  end)

  local handler = ClientInstance.current_request_handler --[[ @as ReqPlayCard ]]
  -- 简单测试can_use：能用就行
  lu.assertIsTrue(handler:cardValidity(slash.id))
  -- 简单测试target_filter：应该只选的到攻击范围内的也就是2和8号位
  handler:selectCard(slash.id, { selected = true })
  lu.assertEquals(table.map(room:getOtherPlayers(me), function(p)
    return not not handler:targetValidity(p.id)
  end), { true, false, false, false, false, false, true })
end)


return jsrg_bahu